<template>
	<view>
		<view>
			<tn-nav-bar alpha backTitle="" :isBack="false"></tn-nav-bar>
			<view :style="{ paddingTop: vuex_custom_bar_height + 'px' }">
			</view>
		</view>
		<view class="content" @click="showMenu = false">
			<view class="top">
				<image class="top-icon" style="width: 55rpx;height: 55rpx;" src="/static/image/icon/menu.png"
					@click.stop="showMenu = true" />
				<view class="top-center">
					<image class="top-icon" src="/static/image/icon/wifi.png" />
					<image class="top-icon" src="/static/image/icon/dian.png" />
					<image class="top-icon-blue" src="/static/image/icon/uv.png" />
				</view>
				<view class="top-switch" :class="{ active: switchOn }" @click="toggleSwitch"></view>
			</view>
			<view class="center u-f-ajc">
				<image src="/static/image/shebeiindex.png" mode="scaleToFill" />
				<!-- <image class="center-icon"
				src="/static/image/shuiindex.png"
				mode="scaleToFill"
			/> -->
			</view>
			<view class="menu">
				<view class="menu-row">
					<view class="menu-card u-f-ajsb">
						<view class="menu-card-header">
							<image class="menu-icon" src="/static/image/icon/lv.png" />
							<text class="menu-label">滤芯</text>
						</view>
						<view class="menu-card-main">
							<text class="menu-main menu-bold">干净</text>
							<view class="menu-dot green"></view>
						</view>
					</view>
					<view class="menu-card u-f-ajsb">
						<view class="menu-card-header">
							<image class="menu-icon" src="/static/image/icon/deng.png" />
							<text class="menu-label">补光灯</text>
						</view>
						<view class="menu-card-main menu-card-switch">
							<view class="menu-switch" :class="{ active: switchOn }" @click="toggleSwitch"></view>
						</view>
					</view>
					<!-- <view class="menu-card">
					<view class="menu-card-header">
						<image class="menu-icon" src="/static/image/icon/sun.png" />
						<text class="menu-label">补光灯</text>
					</view>
					<view class="menu-card-main menu-card-switch">
						<view class="menu-switch" :class="{active: switchOn}" @click="toggleSwitch"></view>
					</view>
				</view> -->
				</view>
				<view class="menu-row">
					<view class="menu-card" style="padding: 30rpx 40rpx;">
						<view class="menu-card-header u-f-ajsb">
							<view>
								<image class="menu-icon" src="/static/image/icon/liang.png" />
								<text class="menu-label">水量</text>
							</view>
							<view class="menu-dot blue"></view>
						</view>
						<view class="menu-card-main menu-card-flex" style="margin-top: 50rpx;">
							<text class="menu-main menu-bold">充足</text>
							<text class=" menu-bold">≈3天</text>
						</view>
					</view>
					<view class="menu-card" style="padding: 30rpx 40rpx;">
						<view class="menu-card-header u-f-ajsb">
							<view>
								<image class="menu-icon" src="/static/image/icon/zhi.png" />
								<text class="menu-label">水质</text>
							</view>
							<view class="menu-dot blue"></view>
						</view>
						<view class="menu-card-main menu-card-flex" style="margin-top: 50rpx;">
							<text class="menu-main menu-bold">理想</text>
						</view>
					</view>

				</view>
			</view>
			<view class="bottom">
				<view class="bottom-btn">
					<image class="bottom-icon" src="/static/image/icon/yuyin.png" />
					<text class="bottom-label">语音</text>
				</view>
				<view class="bottom-btn">
					<image class="bottom-icon" src="/static/image/icon/chushui.png" />
					<text class="bottom-label">一键出水</text>
				</view>
				<view class="bottom-btn disabled" @click="goModelSetting">
					<image class="bottom-icon" src="/static/image/icon/jishi.png" />
					<view>
						<text class="bottom-label">计时模式</text>
						<image class="bottom-disabled" src="/static/image/icon/qie.png" />
					</view>
				</view>
			</view>
			<tn-tabbar v-model="currentIndex" @change="changeTabbar" height="120" bgColor="#000" inactiveColor="#fff"
				activeColor="#fff" :list="tabbarList"></tn-tabbar>

			<!-- 菜单弹窗 -->
			<view v-if="showMenu" class="menu-popup-mask" @click="showMenu = false">
				<view class="menu-popup" @click.stop>
					<view class="menu-popup-item" @click="goInstruction">使用说明</view>
					<view class="menu-popup-item" @click="goDeviceList">设备列表</view>
					<view class="menu-popup-item" @click="goSetting">设备设置</view>
					<view class="menu-popup-item" @click="reset">设备重连</view>
				</view>
			</view>
			<view class="pop" v-if="showBirthday">
				<view class="birthday-popup" style="position: relative;">
					<view class="birthday-bg-text">HAPPY<br />BIRTHDAY</view>
					<view class="birthday-avatar-wrap">
						<image class="birthday-crown" src="/static/image/huangguan.png" />
						<image class="birthday-avatar" :src="catAvatar" />
					</view>
					<image class="birthday-cake" src="/static/image/dangao.png" />
					<view class="birthday-date">2025.09.15　星期三</view>
					<view class="birthday-title">今天是小咪的生日！</view>
					<view class="birthday-desc">这是小咪陪伴你的第532天</view>
					<text class="tn-icon-close-circle" @click="showBirthday = false"
						style="position: absolute;bottom: -100rpx;color: #fff;font-size: 50rpx;"></text>
				</view>
			</view>
		</view>
	</view>

</template>

<script>
export default {
	data() {
		return {
			tabbarList: [{
				title: '首页',
				activeIcon: '/static/image/tabbar/homea.png',
				inactiveIcon: '/static/image/tabbar/home.png'
			},
			{
				title: '数据',
				activeIcon: '/static/image/tabbar/dataa.png',
				inactiveIcon: '/static/image/tabbar/data.png'
			},

			{
				title: '摄影',
				activeIcon: '/static/image/tabbar/shexianga.png',
				inactiveIcon: '/static/image/tabbar/shexiang.png'
			},
			{
				title: '我的',
				activeIcon: '/static/image/tabbar/mya.png',
				inactiveIcon: '/static/image/tabbar/my.png'
			}
			],
			currentIndex: 0,
			title: 'Hello',
			switchOn: true,
			showMenu: false,
			showBirthday: false,
			catAvatar: '/static/image/cat.png'
		}
	},
	onLoad() {
		if (!uni.getStorageSync('token')) {
			uni.redirectTo({
				url: '/pages/login/init'
			})
		}
	},
	methods: {
		goModelSetting() {
			uni.navigateTo({
				url: '/pages/index/modelSetting'
			})
		},
		reset() {
			this.showMenu = false
			uni.navigateTo({
				url: '/pages/device/wifi/index'
			})
		},
		goInstruction() {
			this.showMenu = false

			uni.navigateTo({
				url: '/pages/index/instruction?type=wifi'
			})
		},
		goDeviceList() {
			this.showMenu = false
			uni.navigateTo({
				url: '/pages/device/deviceList'
			})
		},
		goSetting() {
			this.showMenu = false
			uni.navigateTo({
				url: '/pages/index/dervceSetting'
			})
		},
		changeTabbar(index) {
			if (index == 0) {
				uni.redirectTo({
					url: '/pages/index/index'
				})
			} else if (index == 1) {
				uni.redirectTo({
					url: '/pages/data/index'
				})
			} else if (index == 2) {
				uni.redirectTo({
					url: '/pages/video/index'
				})
			}
			else if (index == 3) {
				uni.redirectTo({
					url: '/pages/user/index'
				})
			}
		},
		toggleSwitch() {
			this.switchOn = !this.switchOn
		}
	}
}
</script>

<style>
.menu-bold {
	font-size: 32rpx !important;
	margin-right: 10rpx;
}

.center-icon {
	position: absolute;
	bottom: 75rpx;
	left: 18%;
	width: 65%;
	height: 50%;
	border-radius: 0 0 100rpx 100rpx;
}

.center {
	position: relative;
	margin-top: 140rpx;
}

.content {
	padding: 0rpx 40rpx 20rpx 40rpx;
}

.top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	height: 100rpx;
}

.top-icon {
	width: 44rpx;
	height: 44rpx;
}

.top-icon-blue {
	width: 44rpx;
	height: 44rpx;
	filter: brightness(0) saturate(100%) invert(60%) sepia(94%) saturate(3458%) hue-rotate(200deg) brightness(95%) contrast(101%);
}

.top-center {
	display: flex;
	align-items: center;
	gap: 40rpx;
}

.top-switch {
	width: 80rpx;
	height: 44rpx;
	background: #ddd;
	border-radius: 22rpx;
	position: relative;
	transition: background 0.3s ease;
	cursor: pointer;
}

.top-switch.active {
	background: #000;
}

.top-switch::after {
	content: '';
	position: absolute;
	top: 4rpx;
	left: 4rpx;
	width: 36rpx;
	height: 36rpx;
	background: #fff;
	border-radius: 50%;
	transition: transform 0.3s ease;
}

.top-switch.active::after {
	transform: translateX(36rpx);
}

.menu {
	margin-top: 60rpx;
	padding: 0 rpx;
}

.status-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 50rpx;
	background-color: #fbfbfb;
	border-radius: 20rpx;
	padding: 20rpx;
}

.status-group {
	display: flex;
	align-items: center;
	gap: 12rpx;
	flex: 1;
	justify-content: center;
}

.status-icon {
	width: 32rpx;
	height: 32rpx;
}

.status-label {
	font-size: 26rpx;
	color: #999;
}

.status-text {
	font-size: 26rpx;
	color: #333;
	font-weight: 500;
}

.status-dot {
	width: 12rpx;
	height: 12rpx;
	border-radius: 50%;
}

.status-dot.green {
	background: #00D4AA;
}

.status-dot.blue {
	background: #4db6ff;
}

.status-switch {
	width: 56rpx;
	height: 32rpx;
	background: #ddd;
	border-radius: 16rpx;
	position: relative;
}

.status-switch.active {
	background: #000;
}

.status-switch::after {
	content: '';
	position: absolute;
	top: 3rpx;
	left: 3rpx;
	width: 26rpx;
	height: 26rpx;
	background: #fff;
	border-radius: 50%;
	transition: transform 0.3s ease;
}

.status-switch.active::after {
	transform: translateX(24rpx);
}

.status-bottom {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 0 40rpx;
	margin-top: 40rpx;
}

.status-value {
	font-size: 48rpx;
	font-weight: bold;
	color: #333;
}

.status-time {
	font-size: 36rpx;
	color: #666;
}

.menu-row {
	display: flex;
	justify-content: space-between;
	margin-bottom: 20rpx;
}

.menu-card {
	background-color: #fbfbfb;
	border-radius: 50rpx;
	padding: 9rpx 30rpx;
	width: 320rpx;
	margin-bottom: 18rpx;
	box-shadow: 0 8rpx 32rpx 0 rgba(0, 0, 0, 0.08);
}

.menu-card-header {
	display: flex;
	align-items: center;
}

.menu-icon {
	width: 32rpx;
	height: 32rpx;
	margin-right: 10rpx;
}

.menu-label {
	font-size: 26rpx;
	color: #999;
}

.menu-card-main {
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.menu-main {
	font-size: 26rpx;
	font-weight: 500;
	color: #333;
}

.menu-bold {
	font-weight: bold;
}

.menu-sub {
	font-size: 24rpx;
	color: #666;
}

.menu-card-switch {
	display: flex;
	align-items: center;
}

.menu-switch {
	width: 56rpx;
	height: 32rpx;
	background: #ddd;
	border-radius: 16rpx;
	position: relative;
	cursor: pointer;
}

.menu-switch.active {
	background: #000;
}

.menu-switch::after {
	content: '';
	position: absolute;
	top: 3rpx;
	left: 3rpx;
	width: 26rpx;
	height: 26rpx;
	background: #fff;
	border-radius: 50%;
	transition: transform 0.3s ease;
}

.menu-switch.active::after {
	transform: translateX(24rpx);
}

.menu-card-flex {
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.menu-dot {
	width: 12rpx;
	height: 12rpx;
	border-radius: 50%;
	margin-left: 10rpx;
}

.menu-dot.green {
	background: #00D4AA;
}

.menu-dot.blue {
	background: #4db6ff;
}

.bottom {
	display: flex;
	justify-content: space-around;
	align-items: center;
	padding: 20rpx 0;
	margin-top: 10rpx;
}

.bottom-btn {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 10rpx;
	border-radius: 50rpx;
	background-color: #fff;
	width: 30%;
	height: 186rpx;
	box-shadow: 0 8rpx 32rpx 0 rgba(0, 0, 0, 0.08);
}

.bottom-icon {
	width: 54rpx;
	height: 54rpx;
	margin-bottom: 18rpx;
}

.bottom-label {
	font-size: 26rpx;
	color: #333;
}

.bottom-disabled {
	width: 30rpx;
	height: 20rpx;
	margin-left: 10rpx;
}

.menu-popup-mask {
	position: fixed;
	z-index: 9999;
	left: 0;
	top: 0;
	width: 100vw;
	height: 100vh;
	background: rgba(0, 0, 0, 0.18);
	display: flex;
	align-items: flex-start;
	justify-content: flex-start;
}

.menu-popup {
	margin: 200rpx 0 0 50rpx;
	background: #fff;
	border-radius: 32rpx;
	padding: 40rpx 60rpx;
	display: flex;
	flex-direction: column;
	box-shadow: 0 8rpx 32rpx 0 rgba(0, 0, 0, 0.10);
}

.menu-popup-item {
	font-size: 36rpx;
	color: #111;
	padding: 24rpx 0;
	text-align: center;
}

.menu-popup-item+.menu-popup-item {
	border-top: 1rpx solid #f2f2f2;
}

.pop {
	position: fixed;
	z-index: 9999;
	left: 0;
	top: 0;
	width: 100vw;
	height: 100vh;
	background: rgba(0, 0, 0, 0.38);
	display: flex;
	align-items: center;
	justify-content: center;
}

.birthday-popup {
	width: 90vw;
	max-width: 520rpx;
	background: linear-gradient(180deg, #fffbe7 0%, #fff 100%);
	border-radius: 48rpx;
	box-shadow: 0 8rpx 32rpx 0 rgba(0, 0, 0, 0.10);
	padding: 40rpx 0 40rpx 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	position: relative;
}

.birthday-bg-text {
	position: absolute;
	top: 48rpx;
	left: 0;
	width: 100%;
	text-align: center;
	font-size: 60rpx;
	font-weight: bold;
	color: #f7e7c6;
	letter-spacing: 2rpx;
	opacity: 0.35;
	z-index: 1;
	pointer-events: none;
}

.birthday-avatar-wrap {
	position: relative;
	margin-top: 40rpx;
	z-index: 2;
}

.birthday-crown {
	position: absolute;
	top: -38rpx;
	right: -80rpx;
	transform: translateX(-50%);
	width: 100rpx;
	height: 100rpx;
	z-index: 999;
}

.birthday-avatar {
	width: 150rpx;
	height: 150rpx;
	border-radius: 50%;
	border: 4rpx solid #fff;
	background: #fff;
	z-index: 2;
}

.birthday-cake {
	width: 240rpx;
	height: 300rpx;
	margin-bottom: 32rpx;
	z-index: 2;
}

.birthday-date {
	font-size: 26rpx;
	color: #222;
	text-align: center;
	margin-bottom: 18rpx;
	z-index: 2;
}

.birthday-title {
	font-size: 34rpx;
	font-weight: bold;
	color: #111;
	text-align: center;
	margin-bottom: 10rpx;
	z-index: 2;
}

.birthday-desc {
	font-size: 26rpx;
	color: #444;
	text-align: center;
	z-index: 2;
}
</style>
